package com.ettractions.kiosk.mediators
{
	import com.ettractions.kiosk.components.BrochureAboutView;
	import com.ettractions.kiosk.events.BrochureSelectEvent;
	
	import flashx.textLayout.conversion.TextConverter;
	
	import org.robotlegs.mvcs.Mediator;
	
	public class BrochureAboutMediator extends Mediator
	{
		[Inject]
		public var view:BrochureAboutView;
		
		override public function onRegister():void
		{
			eventDispatcher.addEventListener(BrochureSelectEvent.BROCHURE_SELECTED, handleBrochureSelected);
		}
		
		private function handleBrochureSelected(event:BrochureSelectEvent):void
		{
			if (event.brochure != null)
			{
				var copy:String = "<b>Ettraction Features:</b><br />"
				                + event.brochure.summmary + "<br /><br />"
				                + "<b>Cost:</b> " + event.brochure.cost;
				
				view.copy.textFlow = TextConverter.importToFlow(copy, TextConverter.TEXT_FIELD_HTML_FORMAT);
			}
		}		
	}
}